﻿//创建时间: 2010-12-10
//创建作者: 李 城
//功能说明: 评论设置
//最后修改: 2010-12-10

using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using TRPOP.Common;
using TRPOP.CMS.Web.UI;


using TRPOP.CMS.Business;
using TRPOP.CMS.Model;
using System.Collections;

namespace TRPOP.CMS.Web.Admin
{
    public partial class Recomment_setting : BaseAdmin
    {
        #region 当前页面权限验证
        protected override void SubPageInit()
        {
            base.m_strPagePermissionExtraKey = "Plugin_comment";
        }
        #endregion

        #region 页面变量
        protected string m_Title = "评论设置";
        protected string m_strRefer = "Recomment_list.aspx";
        protected string m_ConfigTypeKey = SYSConfig.RecVar;
        protected string m_ParamKey = SYSConfig.RecParamTypeKey;
        #endregion

        #region 页面事件

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadBase();
            }
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {

            ArrayList oVarArray = SYSConfig.GetVarValue(m_ParamKey, m_ConfigTypeKey);
            CheckConfig(oVarArray);
            oVarArray[1] = rbtRecommentEnableAudit.SelectedValue;
            oVarArray[2] = txtRecommentUsernameLengt.Text.Trim();
            oVarArray[3] = txtRecommentContentMinLength.Text.Trim();
            oVarArray[4] = txtRecommentContentMaxLength.Text.Trim();
            oVarArray[5] = rbtRecommentEnableTextReplace.SelectedValue.Trim();
            oVarArray[6] = txtRecommentTextReplace.Text.Trim();
            oVarArray[7] = txtRecommentTextReplaceList.Text.Trim();
            oVarArray[8] = txtRecommentGetCountUrl.Text.Trim();
            oVarArray[9] = txtRecommentSubmitUrl.Text.Trim();
            oVarArray[10] = txtRecommentListUrl.Text.Trim();
            oVarArray[11] = txtRecommentCheckCodeUrl.Text.Trim();
            oVarArray[12] = txtrecName.Text.Trim();
            oVarArray[13] = txtrecDetail.Text.Trim();
            oVarArray[14] = txtindexid.Text.Trim();
            oVarArray[15] = txtrecvalidCode.Text.Trim();
            base.SaveLog(Plugin.LogKeys.OperObject.PluginOper, Plugin.LogKeys.OperResult.EditSubmit, m_ConfigTypeKey);
            SubmitAlertAndThisNewLocation(SYSConfig.SaveVarValue(Config.VarAray.GetRecommentAttribute(),
                                                                        oVarArray,
                                                                        m_ConfigTypeKey
                                                                        )
                                          , m_strRefer
                                          );
        }

        #endregion

        #region 页面方法

        public void LoadBase()
        {
            ArrayList oVarArray = SYSConfig.GetVarValue(m_ParamKey, m_ConfigTypeKey);
            CheckConfig(oVarArray);
            rbtRecommentEnable.SelectedValue = SYSConfig.RecommentEnable.ToString().ToLower();
            rbtRecommentEnableAudit.SelectedValue = oVarArray[1].ToString().Trim();
            txtRecommentUsernameLengt.Text = oVarArray[2].ToString().Trim();
            txtRecommentContentMinLength.Text = oVarArray[3].ToString().Trim();
            txtRecommentContentMaxLength.Text = oVarArray[4].ToString().Trim();
            rbtRecommentEnableTextReplace.SelectedValue = oVarArray[5].ToString().Trim();
            txtRecommentTextReplace.Text = oVarArray[6].ToString().Trim();
            txtRecommentTextReplaceList.Text = oVarArray[7].ToString().Trim();
            txtRecommentGetCountUrl.Text = oVarArray[8].ToString().Trim();
            txtRecommentSubmitUrl.Text = oVarArray[9].ToString().Trim();
            txtRecommentListUrl.Text = oVarArray[10].ToString().Trim();
            txtRecommentCheckCodeUrl.Text = oVarArray[11].ToString().Trim();
            txtrecName.Text = oVarArray[12].ToString().Trim();
            txtrecDetail.Text = oVarArray[13].ToString().Trim();
            txtindexid.Text = oVarArray[14].ToString().Trim();
            txtrecvalidCode.Text = oVarArray[15].ToString().Trim();
        }
        public void CheckConfig(ArrayList oVarArray)
        {
            if (oVarArray == null || oVarArray.Count < 16)
            {
                Alert("请通过正确的途径进入本页面");
                base.ExecuteJs("window.location.href='" + m_strRefer + "'");
                return;
            }
        }
        #endregion
    }
}
